<%@ page language="java"  pageEncoding="UTF-8" %>
<%@ page import="com.shopping.modean.*" %>
<%@ page import="com.shopping.service.*" %>
<%@ page import="java.util.*" %>

<%
    User u = (User)session.getAttribute("user");
	Cart cart = (Cart)session.getAttribute("cart");
	
%>

<!DOCTYPE html>
<html>
<head>
  <title>购物车</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <script type="text/javascript" src="script/regcheckdata.js"></script>
</head>

<body>
	
	<center>您一共购买了这么多商品：</center>
	<table border="1" align="center">
		<tr>
			<td>商品ID</td>
			<td>商品名称</td>
			<td>商品价格</td>
			<td>购买数量</td>
		</tr>
		<%
		  List<CartItem> items = cart.getItems();
		  for(CartItem item: items) {%>
			<tr>
				<td><%=item.getProductId() %></td>
				<td><%=ProductService.getInstance().detail(item.getProductId()).getDescr() %></td>
				<td><%=item.getPrice() %></td>
				<td><%=item.getCount() %></td>
			</tr>
		  <%}
		%>
		
	</table>
	<center>
	    <p>共<%=cart.getTotalPrice() %>元</p>
	    <p><%=u.getUsername() %>,请确认您的收货信息：</p>
		<form action="order.jsp">
			<p>送货信息</p>
			<textarea name="addr" rows="" cols="">
				<%=u != null ?  u.getAddr() : ""%>
			</textarea><br/>
			<input type="submit" value="下单">	
		</form>
	</center>
	
</body>
</html>